<?php

namespace app\admin\model;

use think\Model;


class Banner extends Model
{

    

    

    // 表名
    protected $name = 'banner';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'jump_type_text',
        'active_type_text'
    ];

    public function getImageAttr($val){
        return cdnurl($val);
    }
    

    
    public function getJumpTypeList()
    {
        return ['1' => __('Jump_type 1'), '2' => __('Jump_type 2'), '3' => __('Jump_type 3'), '4' => __('Jump_type 4')];
    }

    public function getActiveTypeList()
    {
        return ['1' => __('Active_type 1'), '2' => __('Active_type 2')];
    }


    public function getJumpTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['jump_type']) ? $data['jump_type'] : '');
        $list = $this->getJumpTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getActiveTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['active_type']) ? $data['active_type'] : '');
        $list = $this->getActiveTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
